package com.vladimirjosu.backgammon;

import java.util.Stack;

import android.content.Context;
import android.widget.LinearLayout;

import com.vladimirjosu.backgammon.Piece.Type;

public class TablePoint extends Stack<Piece> {
	private int mIndex;
	private static final long serialVersionUID = -6171458649063033210L;
	private Context mContext;
	private LinearLayout mLayout;

	public TablePoint(Context context, int idx, int nrPiece, Type type, LinearLayout layout) {
		mIndex = idx;
		mContext = context;
		mLayout = layout;
		for (int i = 0; i < nrPiece; i++) {
			push(new Piece(mContext, type));
		}
	}

	@Override
	public synchronized Piece peek() {
		return super.peek();
	}

	@Override
	public synchronized Piece pop() {
		return super.pop();
	}

	@Override
	public Piece push(Piece object) {
		mLayout.addView(object);
		return super.push(object);
	}
	public Type getLastPieceType() {
		Type type = Type.UNDEFINED;
		if (!isEmpty()) {
			type = peek().getType();
		}
		return type;
	}

	public int getIndex() {
		return mIndex;
	}
}
